package appfight.level;

import braindamagestudio.com.app.fight.MainGameActivity;
import android.util.Log;
import appfight.map.GameMap;
import appfight.map.GameMap.MapClickedEventHandler;
import appfight.map.GameObjectMap.ObjectClickedEventHandler;
import appfight.map.GameObjectMap;
import appfight.map.MapMainCharacter;
import appfight.map.MapObject;

public class GameLevelMap extends GameLevel {
	
	private GameMap _levelMap;
	private GameObjectMap _levelObjectMap;
	
	public MapMainCharacter _mainCharacter;
	private int mainCharacterInitX = 0;
	private int mainCharacterInitY = 0;
	
	public boolean _walkable = true;
	public int _monsterCount = 0;
	
	@Override
	public void LevelDesign()
	{
		
		int[][] gameMap = CreateGameMap();
		
		MapObject[][] gameObjectMap = CreateObjectMap();

		
		_mainCharacter = new MapMainCharacter(this,MainGameActivity.changedSceneCharacterX ,MainGameActivity.changedSceneCharacterY );
		

		_levelMap = new GameMap(this,gameMap,_mainCharacter);
		
		_mainCharacter.setMap(_levelMap);
		_mainCharacter.SetAt(MainGameActivity.changedSceneCharacterX ,MainGameActivity.changedSceneCharacterY);
		
		_levelObjectMap = new GameObjectMap(this,gameObjectMap,_levelMap,_mainCharacter);
		
		//_camera.setChaseEntity(_mainCharacter.sprite);
		
		_levelMap._mapClicked = new MapClickedEventHandler()
		{

			@Override
			public void MapCoordinateClicked(int X, int Y) {
				// TODO Auto-generated method stub
				Log.d("gameloop", X+":"+Y);
				
				if(_levelMap._blockMap[Y][X] == false && _walkable == true)
				{
					_mainCharacter.MoveTo(X,Y);
				}
			}
		};
		
		_levelObjectMap._objectMapClicked = new ObjectClickedEventHandler()
		{
			@Override
			public void ObjectCoordinateClicked(int X, int Y) {
				// TODO Auto-generated method stub
				Log.d("gameloop", X+":"+Y);
				
				if(_levelMap._blockMap[Y][X] == false && _walkable == true)
				{
					_mainCharacter.MoveTo(X,Y);
				}
			}
		};

		LevelDesignEnd();
		_mainCharacter.AttachToScene();
		
	}
	
	protected int[][] CreateGameMap()
	{
		int[][] gameMap = new int[1][1];

		return gameMap;
		
	}
	
	protected MapObject[][] CreateObjectMap()
	{
		MapObject[][] gameObjectMap = new MapObject[1][1];
		
		return gameObjectMap;
		
	}
	
	protected void LevelDesignEnd(){}
}
